require(['./config'],()=>{
    require(['swiper','template','req','header','footer','jquery'],(Swiper,template,req)=>{
        class Index{
            constructor(){
               this.init()
               this.getHotNews()
               this.getZqData()
            }
            init(){
                var swiper = new Swiper('.swiper-container', {
                    spaceBetween: 30,
                    centeredSlides: true,
                    autoplay: {
                      delay: 2500,
                      disableOnInteraction: false,
                    },
                    pagination: {
                      el: '.swiper-pagination',
                      clickable: true,
                    },
                    navigation: {
                      nextEl: '.swiper-button-next',
                      prevEl: '.swiper-button-prev',
                    },
                  });
            }

            //发送请求玩家热评数据
            getHotNews(){
              req.getIndex1()
               .then(res=>{
                if(res.code===1){
                    this.renderHotNews(res.result_body)
                }
               })
            }
           //渲染 玩家热评数据
           renderHotNews(list){
              const html=template('indexHotNewsTemplate',{list})
            //   console.log(html)
              $('.mc5 .mc5b').html(html)
           }

           //请求姜小虎周边专区数据
           getZqData(){
               req.getIndex2()
               .then(res=>{
                //    console.log(res)
                if(res.code===1){
                    this.renderZq(res.res_body)
                }
               })
           }
           //渲染姜小虎周边专区数据
           renderZq(res){
              const html=template('indexZqTemplate',{list:res})
              $('.mc4b section').html(html)
           }
        }

        return new Index()
    })

})